# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=zziplib

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.13.62
pkgrel=3
pkgdesc="A lightweight library that offers the ability to easily extract data from files archived in a single zip file (mingw-w64)"
arch=('any')
url="http://zziplib.sourceforge.net"
license=("LGPL, MPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "python2" "${MINGW_PACKAGE_PREFIX}-SDL")
depends=( "${MINGW_PACKAGE_PREFIX}-zlib")
optdepends=("${MINGW_PACKAGE_PREFIX}-SDL: SDL_rwops for ZZipLib")
options=('staticlibs' 'strip')
source=("http://downloads.sourceforge.net/zziplib/zziplib-${pkgver}.tar.bz2"
    "configure.patch"
    "mingw-mmap-workaround.patch")
md5sums=('5fe874946390f939ee8f4abe9624b96c'
         'a892a62bc8474df4d9de57751c4e25fa'
         '9307404f1699849cb0f2eaf5e0217d92')

prepare() {
  cd "$srcdir/zziplib-$pkgver"
  patch -Np1 -i $srcdir/configure.patch
  patch -Np1 -i $srcdir/mingw-mmap-workaround.patch
}

build() {
  export PYTHON=/usr/bin/python2
  export PERL=/usr/bin/perl
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --with-zlib=${MINGW_PREFIX} \
    --enable-sdl
  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
}
